﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

public partial class CustomerManage_OrderDocListControl : System.Web.UI.UserControl
{
    public event RepeaterCommandEventHandler ItemCommand;
    public List<string> Selected
    {
        get
        {
            List<string> l = new List<string>();
            foreach (RepeaterItem item in rptORDERDOC.Items)
            {
                CheckBox cb = item.FindControl("chkChoose") as CheckBox;
                if (cb != null && cb.Checked)
                {
                    HiddenField fld = item.FindControl("hfORDERDOC") as HiddenField;
                    if (fld != null)
                    {
                        string id = fld.Value;
                        l.Add(id);
                    }
                }
            }
            return l;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    }

    public void Bind(DataTable l)
    {
        rptORDERDOC.DataSource = l.DefaultView;
        rptORDERDOC.DataBind();
    }

    protected void rptORDERDOC_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (ItemCommand != null)
            ItemCommand(source, e);
    }
    protected void rptORDERDOC_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            string odid = ((HiddenField)e.Item.FindControl("hfORDERDOC")).Value;
            DataSet ds = new BLL.ORDERNOTE().GetOrderNoteById(odid);
            if (ds.Tables[0].Rows.Count > 0)
            {
                HyperLink hl = (HyperLink)e.Item.FindControl("sdss");
                System.Drawing.Color a = System.Drawing.Color.FromName(ds.Tables[0].Rows[0]["ST_COLOR"].ToString().Trim());
                hl.BackColor = a;
                hl.ToolTip = ds.Tables[0].Rows[0]["ON_NOTE"].ToString();
            }
            string usercode = ((Label)e.Item.FindControl("lblUserCode")).Text.Trim();
            string of = ((Label)e.Item.FindControl("lblOF")).ToolTip.Trim();
            //string dt = ((Label)e.Item.FindControl("lblDT")).ToolTip.Trim();
            Model.V_CUSTOMER u = new BLL.V_CUSTOMER().GetModel(usercode);
            Model.ORDERFROM f = new BLL.ORDERFROM().GetModel(of);
            //Model.DEALTYPE d = new BLL.DEALTYPE().GetModel(dt);
            ((Label)e.Item.FindControl("lblUserName")).Text = u.GKMC;
            ((Label)e.Item.FindControl("lblOF")).Text = f.OF_NAME;
            //((Label)e.Item.FindControl("lblDT")).Text = d.DT_NAME;
        }

    }
}
